package papers;

/**
 * 
 * @author Matt
 *
 */

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import users.Author;
import users.Reviewer;


public class Manuscript implements Serializable{
	
	private static final long serialVersionUID =
			-7201232457793120541L;
	private Author my_Author;
	private List<Reviewer> my_Reviewers;
	private Date my_SubmissionDate;
	private Status my_Status = Manuscript.Status.UNDECIDED;
	private ArrayList<Review> my_Reviews = new ArrayList<Review>();
	private String my_Title;
	private File my_PaperFile;
	
	/**
	 * Creates a Manuscript object.
	 * 
	 * @param author the Author who wrote the Manuscript.
	 * @param date the Date that the review is turned in.
	 * @param paperName the name of the Manuscript.
	 * @param review the file holding the review.
	 */
	public Manuscript(Author author, Date date, String paperName, File file){
		this.my_Author = author;
		my_SubmissionDate = date;
		my_Title = paperName;
		my_PaperFile = file;	
		my_Reviewers = new ArrayList<Reviewer>();
	}
	
	/**
	 * Gets the actual manuscript file.
	 * 
	 * @return myPaperFile, the manuscript file.
	 */
	public File getPaper(){
		return my_PaperFile;
	}
	
	/**
	 * Gets the name of the Manuscript.
	 * 
	 * @return myTitle, the title of the manuscript
	 */
	public String getPaperName(){
		return my_Title;
	}
	
	/**
	 * Gets the Author of the manuscript.
	 * 
	 * @return myAuthor, the Author of the manuscript.
	 */
	public Author getAuthor(){
		return my_Author;
	}
	
	/**
	 * Gets the Date the Manuscript was submitted.
	 * 
	 * @return mySubmissionDate, the date the manuscript was submitted.
	 */
	public Date getSubmissionDate(){
		return my_SubmissionDate;
	}
	
	/**
	 * Gets the list of Reviewers for the Manuscript.
	 * 	
	 * @return myReviewers, the List of Reviewers of a Manuscript.
	 */
	public List<Reviewer> getReviewers() {
		return my_Reviewers;
	}

	/**
	 * Sets the Reviewer List.
	 * 
	 * @param reviewer the Reviewers of a Manuscript.
	 */
	public void setReviewers(List<Reviewer> reviewer) {
		my_Reviewers = reviewer;
	}
	
	/**
	 * Adds a single Reviewer to the List of Reviewers.
	 * 
	 * @param reviewer the new Reviewer to be added to the list.
	 */
	public void addReviewer(Reviewer reviewer) {
		my_Reviewers.add(reviewer);
	}

	/**
	 * Gets the acceptance status of the manuscript.
	 * 
	 * @return myStatus, the yes/no/undecided status of a Manuscript.
	 */
	public Status getStatus() {
		return my_Status;
	}

	/**
	 * Allows the Program Chair to change the status of a Manuscript.
	 * 
	 * @param status the status the Program Chair is changing to.
	 */
	public void setStatus(Status the_status) {
		this.my_Status = the_status;
	}

	/**
	 * Gets all the Reviews associated with a manuscript.
	 * 
	 * @return myReviews, the List of reviews for a manuscript.
	 */
	public ArrayList<Review> getReviews() {
		return my_Reviews;
	}

	/**
	 * Adds a newly completed Review to the Review list.
	 * Calls the method that sets the rating.
	 * 
	 * @param newReview the newly completed Review.
	 */
	public void addReview(Review newReview) {
		my_Reviews.add(newReview);
	}
	/**
	 * 
	 *
	 */
	public enum Status {
		 YES, NO, UNDECIDED;

		public String toString() {
			String s = super.toString();
			return s.substring(0, 1) + s.substring(1).toLowerCase();
		}
	}
	/**
	 * Deletes the review from the manuscript.
	 * @param r
	 */
	public void deleteReview(Review r) {
		my_Reviews.remove(r);
	}
	
}
